#include "contextmenu.h"
#include <QShortcut>

ContextMenu::ContextMenu(QWidget *parent) :
    QMenu(parent)
{
    //Context menu
    open = new QAction(tr("Open"), this);
    addAction(open);
    connect(open, SIGNAL(triggered()), this, SIGNAL(openTriggered()));

    addSeparator();
    cut = new QAction(tr("Cut"), this);
    addAction(cut);
    connect(cut, SIGNAL(triggered()), this, SIGNAL(cutTriggered()));
    copy = new QAction(tr("Copy"), this);
    addAction(copy);
    connect(copy, SIGNAL(triggered()), this,SIGNAL(copyTriggered()));
    paste = new QAction(tr("Paste"), this);
    addAction(paste);
    paste->setDisabled(true);
    connect(paste, SIGNAL(triggered()), this, SIGNAL(pasteTriggered()));

    addSeparator();
    del = new QAction(tr("Delete"), this);
    addAction(del);
    connect(del, SIGNAL(triggered()), this, SIGNAL(deleteTriggered()));;
    rename = new QAction(tr("Rename"), this);
    addAction(rename);
    connect(rename, SIGNAL(triggered()), this,SIGNAL(renameTriggered()));

    addSeparator();
    fbNewMenu=new QMenu(tr("New"));
    addFolder = new QAction(tr("Folder"), this);
    connect(addFolder,SIGNAL(triggered()),this,SIGNAL(createFolderTriggered()));

    fbNewMenu->addAction(addFolder);
    addMenu(fbNewMenu);
}

void ContextMenu::addContextMenuAction(QAction *action){
    addAction(action);
}

void ContextMenu::addContextMenuMenu(QMenu *menu){
    addMenu(menu);
}


void ContextMenu::addContextMenuSeparator(){
    addSeparator();
}

void ContextMenu::removeFromContextMenu(QAction *action){
    removeAction(action);
}

QList <QAction *> ContextMenu::contextMenuActions(){
    return actions();
}

void ContextMenu::setNewFolderEnabled(bool enabled){
    addFolder->setEnabled(enabled);
}

void ContextMenu::setPasteEnabled(bool enabled){
    paste->setEnabled(enabled);
}

void ContextMenu::setDeleteEnabled(bool enabled){
    del->setEnabled(enabled);
}

void ContextMenu::setRenameEnabled(bool enabled){
    rename->setEnabled(enabled);
}

void ContextMenu::setOpenEnabled(bool enabled){
    open->setEnabled(enabled);
}
